home *** CD-ROM | disk | FTP | other *** search
- /*
-
- ChatPanel.js
-
-
- */
-
- //create template for user management.
-
- function chatPanelObj(){
-
- this.chatPanelAddScreenName = chatPanelAddScreenName;
- this.chatPanelRemoveScreenName = chatPanelRemoveScreenName;
- this.chatPanelUpdateScreenName = chatPanelUpdateScreenName;
-
- return this;
- }
-
- myChatPanel = new chatPanelObj()
-
-
- function chatPanelOnWinLoad(){
-
- try{
-
- if(parent.myManager && parent.chatPanelLoaded){
- dump("chatPanelOnWinLoad - parent.myManager defined \n")
- for(z=0;z<parent.myManager.members.length;z++){
- chatPanelUpdateScreenName(parent.myManager.members[z].screenName,parent.myManager.members[z].status)
- }
-
- }
- else{
- dump("chatPanelOnWinLoad -parent.myManager not defined \n")
- }
- }
- catch (e){
- dump("chatPanelOnWinLoad : couldnt find parent.myManager (caught exception) \n")
- }
-
- parent.chatPanelLoaded=true;
- }
-
-
- function chatPanelAddScreenName(screenName,initialState){
- dump('adding:'+screenName+"\n\n")
- //get current tree
- theTree = document.getElementById("cptChildren");
- // build new tree branch
- newTreeItem=document.createElement("treeitem");
- newTreeItem.setAttribute('value',screenName)
-
- newTreeRow=document.createElement("treerow");
- newTreeCell=document.createElement("treecell");
- //newTreeCell.setAttribute('src','chrome://aim/skin/aimworld.gif');
- newTreeCell.setAttribute('value',screenName);
- newTreeCell.setAttribute('class',initialState);
-
- dump("chatPanelAddScreenName adding class value of"+initialState);
-
- newTreeRow.appendChild(newTreeCell)
- newTreeItem.appendChild(newTreeRow)
-
- theTree.appendChild(newTreeItem)
-
- top.updateMemberCount();
- //top.updateStatus(screenName+" > "+initialState)
- top.chatContentStatusChange(screenName,initialState)
-
-
- }
-
-
- function chatPanelRemoveScreenName(screenName){
- dump('removing:'+screenName+'\n\n')
- theTree = document.getElementById("cptChildren");
- //theDoomedScreenName = document.getElementById(screenName)
-
- //theDoomedScreenName = document.getElementsByAttribute('value',screenName.toLowerCase()).item(0)
-
- var theTreeChildren = document.getElementsByTagName("treecell");
- var theDoomedScreenName = null;
-
- for(k=0; k<theTreeChildren.length; k++){
- if(theTreeChildren.item(k).getAttribute("value").toLowerCase() == screenName.toLowerCase()){
- theDoomedScreenName = theTreeChildren.item(k);
- }
-
- }
-
- if(theDoomedScreenName != null){
-
- theTree.removeChild(theDoomedScreenName.parentNode.parentNode)
- top.updateMemberCount();
- //top.updateStatus(screenName+"has left")
- top.chatContentStatusChange(screenName,"has left")
-
- }
- else{
- dump("chatPanelRemoveScreenName: cannot remove "+screenName+"\n");
- }
-
-
- }
-
- //update the status of a given screenname
-
- function chatPanelUpdateScreenName(screenName,snStatus){
- dump("updating status of "+screenName+" to "+snStatus+"\n");
- //var searchingSN = screenName.toLowerCase()
- //var theSNtoUpdate = document.getElementById(searchingSN)
- var theTreeChildren = document.getElementsByTagName("treecell");
- var theSNtoUpdate= null;
- for (j=0; j<theTreeChildren.length; j++){
- if(aimIsSameScreenName(theTreeChildren.item(j).getAttribute("value"), screenName)){
- theSNtoUpdate = theTreeChildren.item(j);
- dump("ChatPanelUpdate:found the child +\n" )
- }
- }
-
-
-
- if(theSNtoUpdate!=null){
- dump("they already were here in some state.(invited?)\n")
- theSNtoUpdate.setAttribute("class",snStatus);
-
- // in case its formatting has changed
- theSNtoUpdate.setAttribute("value", screenName);
- top.updateMemberCount();
-
- top.chatContentStatusChange(screenName,snStatus)
-
- }
- else{
- dump(" they joined without being invited? \n")
- chatPanelAddScreenName(screenName,snStatus)
- }
-
- }
-
-
- function cmdUserSelected(e){
- document.getElementById("userSelected").setAttribute("disabled","false")
- //var targetValue=e.target.getAttribute("value");
-
- //dump("userSelected:"+targetValue+"\n")
- var theTree = document.getElementById("chatPanelTree")
- if(theTree.selectedItems.length==1){
- dump('elementSelected:' + theTree.selectedItems[0].tagName +"\n")
- document.getElementById("userSelected").setAttribute("disabled","false")
-
- }
- if(theTree.selectedItems.length==0){
- document.getElementById("userSelected").setAttribute("disabled","true")
-
- }
-
- }
-
- function cmdUserBlurred(e){
- //document.getElementById("userSelected").setAttribute("disabled","true")
- dump("userBlurred:"+e.target.tagName+"\n")
-
- }
-
-
-
- function cmdSendIMFromChat(){
- var theTree = document.getElementById("chatPanelTree")
- if(theTree.selectedItems.length==1){
- var selectedScreenName =theTree.selectedItems[0].childNodes[0].childNodes[0].getAttribute("value")
-
- aimIMInvokeIMForm(selectedScreenName, null);
-
- }
- }
-
- function cmdIgnoreFromChat()
- {
- var theTree = document.getElementById("chatPanelTree")
- var i;
- for (i = 0; i < theTree.selectedItems.length; i++)
- {
- var selectedScreenName =theTree.selectedItems[i].childNodes[0].childNodes[0].getAttribute("value");
-
- var wasIgnored = top.chatRoomObj.Ignore(selectedScreenName);
- if (wasIgnored)
- top.frames['chatpanel'].chatPanelUpdateScreenName(selectedScreenName, "joined treecell-iconic");
- else
- top.frames['chatpanel'].chatPanelUpdateScreenName(selectedScreenName, "ignored treecell-iconic");
-
- }
- }
-
- function getInfoFromChat()
- {
- return;
- }
-
-
-
-